<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <my-dom src="https://zh-hans.legacy.reactjs.org/docs/lifting-state-up.html"></my-dom>
    <script>
        async function loadFile(src) {
            return await fetch(src).then(res => res.text());
        }
        class MyDom extends HTMLElement{
            constructor() {
                super();
                this.src = this.getAttribute("src");
            }
            async connectedCallback(){
                var html = await loadFile(this.src);
                var attachShadow = this.attachShadow({mode: 'closed'});
                var div = document.createElement("div");
                div.innerHTML = html;
                attachShadow.appendChild(div);
            }
        }
        
        window.customElements.define("my-dom", MyDom);
    </script>
</body>
</html>